'''
Created on 12.09.2009

@author: ankstoo
'''

from pygs.logger import logger
#from pygs.statusProvider import StatusProvider

class BaseService(object):
    """
        Base implementation for Pygs service
    """
    
    serviceProvider = None
    params = None
#    logger = CreateLogger()

#    def CreateLogger(self):
#        pass;

    def setServiceProvider(self, serviceProvider):
        self.serviceProvider = serviceProvider

    def getServiceProvider(self):
        assert self.serviceProvider, "Service Provider is not set!"
        return self.serviceProvider

    def startup(self, params = None):
        logger.log("Starting up service '%s'..." % self)

    def shutdown(self):
        logger.log("Shutting down service '%s'..." % self)

    def restart(self, params = None):
        logger.log("Restarting service '%s'..." % self)
        self.shutdown()
        if params:
            self.params = params
        self.startup(params)
        